import {
	defineConfig
} from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import path from 'path';

export default defineConfig({
	plugins: [uni()],
	resolve: {
		// 必须配置路径别名
		alias: {
			'@': path.resolve(__dirname, 'static'),
			'~@': path.resolve(__dirname, 'static') // 兼容 nvue 的特殊别名需求
		}
	},
	build: {
		rollupOptions: {
		  external: ["android.serialport.SerialPort","android.serialport.SerialPortFinder"], // 标记为外部依赖
		},
		assetsInlineLimit: 0,
		terserOptions: {
			compress: {
				drop_console: true
			}
		}
	},
	css: {
		preprocessorOptions: {
			nvue: {
				// 移除全局注入，改为各组件单独引入
				// additionalData: "" 
			}
		}
	}
});